using System.IO;
using UnityEditor;
using UnityEngine;

public class UploadTool
{
    [MenuItem("热更/上传全部", false, 100)]
    public static void UploadAll()
    {
        AliyunOSSTool.UploadDirectory("Android/System");
        AliyunOSSTool.UploadDirectory("Android/App");
        AliyunOSSTool.UploadDirectory("Windows/System");
        AliyunOSSTool.UploadDirectory("Windows/App");
    }
    [MenuItem("热更/上传APK文件", false, 101)]
    public static void UploadApkFile()
    {
        AliyunOSSTool.UploadFile("Android/千姿.apk");
    }

    [MenuItem("热更/System/上传全部", false, 102)]
    public static void UploadSystemAll()
    {
        AliyunOSSTool.UploadDirectory("Android/System");
        AliyunOSSTool.UploadDirectory("Windows/System");
    }
    [MenuItem("热更/System/上传Core代码文件", false, 201)]
    public static void UploadCoreDllFile()
    {
        CopyDll("HybridCLRData/HotUpdateDlls/Android/Core.dll", "Data/Android/System/Core.dll");
        CopyDll("HybridCLRData/HotUpdateDlls/StandaloneWindows64/Core.dll", "Data/Windows/System/Core.dll");
        AliyunOSSTool.UploadFiles(new string[] { "Android/System/Core.dll", "Windows/System/Core.dll" });
    }
    [MenuItem("热更/System/上传Core资源文件", false, 202)]
    public static void UploadCoreResFile()
    {
        AliyunOSSTool.UploadFiles(new string[] { "Android/System/Core.res", "Windows/System/Core.res" });
    }
    [MenuItem("热更/System/上传Character资源文件", false, 203)]
    public static void UploadCharacterFile()
    {
        AliyunOSSTool.UploadDirectory("Android/System/Character");
    }
    [MenuItem("热更/System/上传World资源文件", false, 204)]
    public static void UploadWorldFile()
    {
        AliyunOSSTool.UploadDirectory("Android/System/Scene");
    }

    [MenuItem("热更/App/上传全部", false, 103)]
    public static void UploadAppAll()
    {
        AliyunOSSTool.UploadDirectory("Android/App");
        AliyunOSSTool.UploadDirectory("Windows/App");
    }
    [MenuItem("热更/App/上传Supermarket App", false, 201)]
    public static void UploadSupermarket()
    {
        UploadApp("Supermarket");
    }
    [MenuItem("热更/App/上传ChimeBells App", false, 202)]
    public static void UploadChimeBells()
    {
        UploadApp("ChimeBells");
    }

    public static void UploadApp(string name)
    {
        CopyDll("HybridCLRData/HotUpdateDlls/Android/" + name + ".dll", "Data/Android/App/" + name + "/" + name + ".dll");
        CopyDll("HybridCLRData/HotUpdateDlls/StandaloneWindows64/" + name + ".dll", "Data/Windows/App/" + name + "/" + name + ".dll");
        AliyunOSSTool.UploadDirectory("Android/App/" + name);
    }
    public static void CopyDll(string oldNmae, string newNmae)
    {
        if (File.Exists(oldNmae))
        {
            if (File.Exists(newNmae))
            {
                File.Delete(newNmae);
            }
            File.Copy(oldNmae, newNmae);
        }
        else
        {
            Debug.LogWarning(oldNmae + "文件不存在");
        }
    }

}
